package com.ws.common.base;

import cn.hutool.core.util.StrUtil;
import com.ws.common.constant.BaseConstants;
import com.ws.common.utils.SessionUtils;

import java.util.Date;

public class BaseUtils {

    public static void setDefault(BaseEntity t){
        BaseEntity user=SessionUtils.get("user");
        if(StrUtil.isEmpty(t.getId())){
            t.setIsDeleted(BaseConstants.NO);
            t.setCreateTime(new Date());
            t.setUpdateTime(new Date());
            t.setCreator(user.getId());
            t.setUpdatedby(user.getId());
        }else{
            t.setUpdatedby(user.getId());
            t.setUpdateTime(new Date());
        }
    }

}
